import { storeBindingsBehavior } from 'mobx-miniprogram-bindings'
import base from "@src/store/base";

Component({
  options: {
    addGlobalClass: true
  },
  behaviors: [storeBindingsBehavior],
  storeBindings: [{
    store: base,
    fields: ['themeColor', 'themeTitleColor']
  }],

  data: {
    showImage: false,
    //1 :条形码  2：二维码
    type: null,
    list: [],
    dialogVisible: false,
    resolve: null,
    reject: null,
    originScreenBrightness: null,
  },
  methods: {
    dialogShow(img, type) {
      wx.getScreenBrightness({
        success: res => {
          if (res.value < 0.75) {
            wx.setScreenBrightness({ value: 0.75 });
          }
          this.setData({ originScreenBrightness: res.value })
        }
      });
      this.setData({
        showImage: true,
        imgSrc: img,
        type
      })
      wx.setScreenBrightness({
        value: .7
      })
      wx.setKeepScreenOn({
        keepScreenOn: false
      })
    },
    hiddenEnlargeFunc() {
      this.setData({ showImage: false, })
      wx.setScreenBrightness({ value: this.data.originScreenBrightness })
    },

    handleStop() {
      return false;
    }
  }
})
